package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionToArray {
    public static void main(String[] args) {
        //集合转数组
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");

       System.out.println(Arrays.toString(list.toArray(new String[1])));
        //数组转集合 数组与集合共享
        String[] array = new String[3];
        array[0] = "one";
        array[1] = "two";
        array[2] = "three";
        List<String> list1 =Arrays.asList(array);
        System.out.println("list1:"+list1);
        System.out.println("array:"+Arrays.toString(array));
    }
}
